class Debug
	
	def initialize(callerObject)
		@debug = true
		@logging = false
		@callerClass=""
		logfilename = "log/"+Time.new.strftime("%Y%m%d")
		
      if(@logging)
         @logFile = File.open("#{logfilename}.log", "a")
         @logFile.puts " "
       end  
		@callerObject=callerObject
	end
	
	
	def msgg(message)
			outmsg = Time.new.strftime("%Y%m%d %H:%M:%S")
			#outmsg << ": "+@callerClass+" "+message
			outmsg << ": "+(@callerObject.class.to_s.upcase+":").ljust(10)+message
		if(@debug)		
		#if @consoleConnected
			#if @consoleSocket!=nil
			
			#	@consoleSocket.puts outmsg+"\r\n"
			if @consoleConnected
				@consoleDescriptors.each do |clisock|
					if clisock != @consoleServerSocket# && clisock != omit_sock
						clisock.puts(outmsg+"\r\n")
					end
			end
		end
		puts outmsg
      if(@logging)
         @logFile.puts outmsg
         @logFile.flush
		end
		#check for console
		#if(@callerObject.consoleConnected)
		#	puts "Got a console"
		#end
		
		end
	end
end